/**
//不在使用，websocket功能由 websocketObj.js实现
let isClosed = false;
let reconnectCount = 5;
let heartbeatInterval = null;
let socketTask = null;

let reconnectTimer = null;

let url = null;
let onReFn = null;
let onSucFn = null;
let onErrFn = null;

const socket = (socketUrl,onReceive,onErrorEvent,onSuccess) => {
	url = socketUrl;
	onReFn = onReceive;
	onErrFn = onErrorEvent;
	onSucFn = onSuccess;
	isClosed = false;
	if(socketTask){
		socketTask.close();
		socketTask = null;
		clearInterval(heartbeatInterval);
	}
	
	setTimeout(() =>{
		console.log("do nothing...")
	},500);
	
	socketTask = uni.connectSocket({
		url:url,
		success(data) {
			clearInterval(reconnectTimer);
		},
		fail(err) {
			
		}
	});
	
	socketTask.onOpen((res) =>{
		clearInterval(reconnectTimer);
		heartbeatInterval = setInterval(() =>{
			sendMsg('-heartbeat-')
		},3000);
	});
	
	socketTask.onError((err) =>{
		clearInterval(heartbeatInterval);
		if(!isClosed){
			reconnect(url,onErrFn);
		}
	});
	
	socketTask.onClose((e) =>{
		clearInterval(heartbeatInterval);
		if(!isClosed){
			reconnect(url,onErrFn);
		}
	});
	
	socketTask.onMessage((res) =>{
		uni.hideLoading();
		let serverData = res.data;
		serverData && onReceive(serverData);
	})
}

const reconnect = (url,onErrorEvent) =>{
	clearInterval(reconnectTimer);
	clearInterval(heartbeatInterval);
	socketTask && socketTask.close();
	socketTask = null;
	onErrorEvent({message:'websocket reconnecting....'});
	reconnectTimer = setInterval(() =>{
		socket(url,onReFn,onErrFn.onSucFn)
	},50000);
}

const sendMsg = (msg)=>{
	msg = JSON.stringify(msg);
	try{
		socketTask.send({data:msg});
	} catch(e) {
		if(isClosed){
			return;
		}else{
			reconnect(url,onErrFn);
		}
	}
}

const stop = ()=>{
	isClosed = true;
	clearInterval(heartbeatInterval);
	clearInterval(reconnectTimer);
	socketTask.close();
	socketTask = null;
}

const onMessageRecived = (msg) =>{
	uni.$emit("websocket_msg_rcv");
}

const onWebSocketError = (err) =>{
	
}

const onWebSocketSuccess = (res) =>{
	
}

const install = (Vue,vm) =>{
		const wsUrl = 'ws://'+vm.vuex_host+':'+vm.vuex_port+'/websocket/message/'+vm.vuex_token;
		socket(wsUrl,onMessageRecived,onWebSocketError,onWebSocketSuccess);
}


export default{	
	install,
	stop,
	sendMsg
}

**/